<template>
	<view>
		<view class="loading_page" :style="{backgroundColor: bgColor}" :animation="loadAnim" :hidden="!loadFlag">
			<image src="../../static/images/loading.gif"></image>
		</view>
	</view>
</template>

<script>
	export default {
		name:"maoeu-loading",
		props:{
			// 背景颜色
			bgColor:{
				type: String,
				default: '#FFFFFF'
			},
		},
		data() {
			return {
				loadAnim: '',
				loadFlag: true,
			};
		},
		methods:{
			openLoading(){
				var that = this
				that.loadFlag = true
			},
			closeLoading(){
				var that = this
				var animation = uni.createAnimation({
				  duration: 200,
				  timingFunction: 'linear',
				})
				animation.opacity(0).step()
				that.loadAnim = animation.export()
				setTimeout(function(){
					that.loadFlag = false
				},200)
			}
		}
	}
</script>

<style lang="scss">
	.loading_page {
		width: 100vw;
		height: 100vh;
		display: flex;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9;
		align-items: center;
		justify-content: center;
		image {
			width: 180rpx;
			height: 180rpx;
			position: relative;
			margin-top: -100rpx;
			/* #ifdef h5 */
			margin-top: 0;
			/* #endif */
		}
	}
</style>
